package biz.impl;

import biz.UserBiz;
import dao.UsersDao;
import pojo.Teams;
import pojo.UserRoleProject;
import pojo.Users;
import util.DateTransfrom;

/** 
* @author WuYuan
* 
*/
public class UserBizImpl implements UserBiz {
	private UsersDao usersDao;
	
	public UsersDao getUsersDao() {
		return usersDao;
	}

	public void setUsersDao(UsersDao usersDao) {
		this.usersDao = usersDao;
	}

	@Override
	public Users login(Users u) {
		try {
			return usersDao.findUserByUser(u);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public int addregister(Users u)  {
		try {
			u.setCreateDate(DateTransfrom.getSystemDate());
			return usersDao.addUser(u);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
	}

	@Override
	public Users validateUser(String username) {
		try {
			return usersDao.findUserByUsername(username);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Teams judgeUserAndTeam(String userid, String teamid) {
		// TODO Auto-generated method stub
		try {
			return usersDao.findTeamByUandT(userid, teamid);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public UserRoleProject findUrpidByURP(String userid, String roleid, String projectid) {
		// TODO Auto-generated method stub
		try {
			return usersDao.findUrpidByURP(userid, roleid, projectid);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

}
